package com.sservice.banfu.service.impl;

import com.sservice.banfu.e.Tpl;
import com.sservice.banfu.mapper.TplMapper;
import com.sservice.banfu.service.TplService;
import com.sservice.banfu.vo.TplVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by byte_su@163.com on 2018/02/05.
 */
@Service
public class TplServiceImpl implements TplService {

    @Autowired
    private TplMapper tplMapper;


    @Override
    public List<Tpl> reformatContent(List<Tpl> list) {
        for (Tpl tpl : list) {
            tpl.setRemark(tpl.getContent() != null ? new String(tpl.getContent()) : "");
        }
        return list;

    }


    @Override
    public int setHome(Integer id) {
//        Condition condition = new Condition(Tpl.class);
        return 0;
//        condition.createCriteria().andEqualTo("plain").equals("HOME");
//        List<Tpl> list = this.findByCondition(condition);
//        if (list.size() > 0) {
//            Tpl tpl = list.get(0);
//            tpl.setPlain("N/A");
//            this.update(tpl);
//        }
//        Tpl tpl1 = new Tpl();
//        tpl1.setId(id);
//        tpl1.setPlain("HOME");
//        return this.update(tpl1);
    }

    @Override
    public int delete(Integer id) {
        return tplMapper.delete(id);
    }

    @Override
    public Tpl selectById(Integer id) {
        return tplMapper.selectById(id);
    }

    @Override
    public int save(Tpl id) {
        return tplMapper.save(id);
    }

    @Override
    public int update(Tpl id) {
        return tplMapper.update(id);
    }

    @Override
    public List<Tpl> queryByPage(TplVo record) {
        return tplMapper.selectByPage(record);
    }

    @Override
    public int countByPage(TplVo record) {
        return tplMapper.countByPage(record);
    }
}
